home *** CD-ROM | disk | FTP | other *** search
- #!/bin/bash
- #
- # Network hotplug policy agent for Linux 2.4 kernels
- #
- # Kernel NET hotplug params include:
- #
- # ACTION=%s [register or unregister]
- # INTERFACE=%s
- #
- # HISTORY:
- #
- # 25-Feb-2001 Special case ppp and similar (redhat)
- # 23-Jan-2001 Log invocation of "ifup" if debugging
- # 04-Jan-2001 Initial version of "new" hotplug agent.
- #
- # $Id: net.agent,v 1.9 2001/09/07 15:57:39 dbrownell Exp $
- #
-
- cd /etc/hotplug
- . hotplug.functions
- # DEBUG=yes export DEBUG
-
- if [ "$INTERFACE" = "" ]; then
- mesg Bad NET invocation: \$INTERFACE is not set
- exit 1
- fi
-
- case $ACTION in
- register)
-
- case $INTERFACE in
- # interfaces that are registered after being "up" (?)
- ppp*|ippp*|isdn*|plip*|lo*|irda*|tunl*)
- debug_mesg assuming $INTERFACE is already up
- exit 0
- ;;
- # interfaces that are registered then brought up
- *)
- # conform to network service
- [ -r /etc/sysconfig/network ] && . /etc/sysconfig/network
-
- CFG=/etc/sysconfig/network-scripts/ifcfg-$INTERFACE
- PCMCIA=/var/lib/pcmcia/stab
-
- if [ "$AUTOMATIC_IFCFG" != no -a "${INTERFACE:0:3}" == "eth" -a ! -r $CFG ]; then
- if [ -r $PCMCIA ] && grep -q "$INTERFACE$" $PCMCIA; then
- ONBOOT=no
- else
- ONBOOT=yes
- fi
- debug_mesg creating config file for $INTERFACE
- cat > $CFG <<EOF
- DEVICE=$INTERFACE
- BOOTPROTO=dhcp
- ONBOOT=$ONBOOT
- EOF
- fi
-
- if [ -r $CFG ]; then
- # Mandrake Linux and similar
- if [ "${INTERFACE:0:3}" == "eth" -a -x /sbin/ifplugd ] && ! grep -q '^MII_NOT_SUPPORTED' $CFG; then
- IFPLUGD_ARGS="${IFPLUGD_ARGS=-w -b}"
- debug_mesg invoke ifplugd $INTERFACE
- exec /sbin/ifplugd $IFPLUGD_ARGS -i $INTERFACE >/dev/null
- fi
-
- # RedHat and similar
- if [ -x /sbin/ifup ]; then
- debug_mesg invoke ifup $INTERFACE
- exec /sbin/ifup $INTERFACE >/dev/null
- else
- mesg "how do I bring interfaces up on this distro?"
- fi
- fi
- ;;
- esac
- mesg $1 $ACTION event not handled
- ;;
-
- *)
- debug_mesg NET $ACTION event not supported
- exit 1 ;;
-
- esac
-